package com.yazi.mxz.gather.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;


import com.myframework.smhj.hibernate.dao.BasicDao;
import com.yazi.mxz.gather.dao.StoreGoodsDao;
import com.yazi.mxz.gather.entity.beans.Store;
import com.yazi.mxz.gather.entity.beans.StoreGoods;

/**
 * 
 * @author mo_yq5
 * @date 2014-2-1
 */
@Repository("storeGoodsDao")
public class StoreGoodsDaoImpl extends BasicDao<StoreGoods> implements StoreGoodsDao {


	public StoreGoodsDaoImpl() {
		super(StoreGoods.class);
	}

	@Override
	public Criteria getExample(StoreGoods storeGoods, String searchWord) {
		Criteria c = createCriteria(StoreGoods.class);
		
		Example example = Example.create(storeGoods);
		c.add(example);
		
		Store store = storeGoods.getStore();
		if (null != store) {
			// 店铺ID
			if (null != store.getStoreId()) {
				c.add(Restrictions.eq("store.storeId", store.getStoreId()));
			} else {
				//...店铺的其它条件
			}
			
		}
		
		return c;
	}

}
